import { ReqPage, ResPage } from '@/api/interface'
import { TBY } from '@/api/config/servicePort'
import http from '@/api'
import { AnimalPlant } from '@api/tby/summarize/animalPlant/interface'

/**视图 */
export namespace EducationView {
  /**查询参数 */
  export interface Query extends ReqPage {
    type?: string
    category: string
    createTime?: any
    createTimeBegin?: string
    createTimeEnd?: string
    businessId?: number
    typeLevel?: number
  }

  /**列表内容 */
  export interface Record {
    id: number
    /**物种或宣教馆*/
    category: string
    categoryValue: string
    /**图片或视频*/
    type: string
    typeValue: string
    /**物种id或宣教馆id*/
    businessId: number
    businessName: string
    fileUrl: string
    fileSize: number
    fileName: string
    createDateFormat: string
  }

  /**详情 */
  export interface Form {
    id: number
    category: string
    type: string
    businessId: any
    fileUrl: string
    fileSize: number
    fileName: string
    fileSuffix: string
  }

  export interface WzForm {
    id: number
    category: string
    type: string
    wzType: any
    wzSelectData: AnimalPlant.Record[]
    businessId: any
    fileUrl: string
    fileSize: number
    fileName: string
    fileSuffix: string
  }

  /**类型枚举 */
  export const TypeEnum = [
    { value: 'VIDEO', label: '视频' },
    { value: 'IMAGE', label: '图片' }
  ]
}

// 分页查询
export const pageEducationView = (params: EducationView.Query) => {
  return http.get<ResPage<EducationView.Record>>(TBY + `/education_view/page`, params)
}

// 详情
export const getEducationViewDetail = (id: number) => {
  return http.get<Partial<EducationView.Form>>(TBY + `/education_view/get`, { id }, { loading: false })
}

// 新增
export const saveEducationView = (content: string) => {
  return http.post(TBY + `/education_view/save`, { formData: content })
}

// 修改
export const updateEducationView = (ids: string, businessId: number) => {
  return http.post(TBY + `/education_view/update`, { ids: ids, businessId: businessId })
}

// 删除
export const removeEducationView = (id: number) => {
  return http.delete(TBY + `/education_view/delete`, { id })
}
